//表单配置项
const formItemData = {
  'inputGroup': {
    formType: 'inputGroup',
    items: [
      {
        itemConfig: {
          name: 'timeType'
        },
        elConfig: {
          formType: 'noLabelSelect',
          placeholder: '时间类型',
          options: [
            { label: '完成时间', value: '2' },
            { label: '支付时间', value: '3' },
            { label: '入账时间', value: '4' },
          ],
          style: {
            width: '100px'
          }
        }
      },
      {
        itemConfig: {
          name: 'payTime'
        },
        elConfig: {
          formType: 'noLabelRangTime',
          placeholder: ['开始时间', '结束时间'],
          style: {
            width: '332px'
          }
        }
      },
    ],
  },
  'orderSn': {
    itemConfig: {
      name: 'orderSn'
    },
    elConfig: {
      formType: 'Input',
      placeholder: '关联单号',
    }
  },
  'transType': {
    itemConfig: {
      name: 'transType'
    },
    elConfig: {
      formType: 'Select',
      placeholder: '支付环节',
      options: [
        { label: '下单付款', value: '4' },
        { label: '修改商品', value: '13' },
        { label: '拿货换货', value: '43' },
        { label: '拿货改价', value: '12' },
        { label: '订单退款', value: '9' },
        { label: '订单返审核', value: '23' },
        { label: '订单作废', value: '22' },
        { label: '账期还款', value: '26' },
        { label: '拿货退货', value: '10' },
        { label: '仓内拆单', value: '27' },
        { label: '采购付款', value: '28' },
        { label: '采购作废', value: '29' },
        { label: '采购退款', value: '30' },
        { label: '拆分装箱', value: '33' },
        { label: '线下备货', value: '34' },
        { label: '取消线下备货', value: '35' },
        { label: '财审结算', value: '36' },
        { label: '无采购入库', value: '37' },
        { label: '商户退款', value: '42' },
        { label: '其他', value: '20' },
      ]
    }
  },
  'goodsName': {
    itemConfig: {
      name: 'goodsName'
    },
    elConfig: {
      formType: 'Input',
      placeholder: '商品名称',
    }
  },
}

//处理表单数据
export const getFormItem = (type) => {
  const arr = [];
  Object.keys(formItemData).map(key => {
    if (key == 'inputGroup') {
      formItemData[key].items.map(item => {
        if (item.itemConfig.name == 'timeType') {
          return item.elConfig.options = item.elConfig.options.filter(el => {
            if (type == 1) {
              return el.value != 4;
            } else if (type == 2) {
              return el.value == 3;
            } else {
              return el.value != 2;
            }
          })
        }
      })
    }
    arr.push(formItemData[key]);
  })
  console.log(arr, 'arr')
  return arr;
}